import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;

public class test{
public static void main(String[]args){
        HashMap<Integer, String> h1 = new HashMap<>();
        h1.put(1,"Tom");
        h1.put(3,"Lily");
        h1.put(2,"Jerry");
        for(Map.Entry<Integer,String > entry: h1.entrySet()){
                System.out.println(entry.getKey() + entry.getValue());
        }

        //true表示允许按照访问顺序排序
        LinkedHashMap<Integer,String> h2 = new LinkedHashMap<>(15,0.75f,true);
        h2.put(1,"Mary");
        h2.put(3,"Bob");
        h2.put(2,"LOU");
        for(Map.Entry<Integer,String > entry1: h2.entrySet()){
                System.out.println(entry1.getKey() + entry1.getValue());
        }
        //访问顺序
        h2.get(2);
        h2.get(1);
        for(Map.Entry<Integer,String > entry1: h2.entrySet()){
                System.out.println(entry1.getKey() + entry1.getValue());
        }

        HashSet<Integer> s1 = new HashSet<>();
        s1.add(1);
        System.out.println(s1.add(2));//返回值为true
        System.out.println(s1.add(1));//无法add重复元素，返回值为false
        System.out.println(s1.size());//size为2
}
}

